<table class="layui-hide" id="orderList" lay-filter="orderList"></table>
<script type="text/html" id="toolbar"></script>
<script>
layui.use(['table','layer'], function(){
  var table = layui.table;
  var layer = layui.layer;
  
  var orderList = {:json_encode($list)};
  var factoryKV = {:json_encode($factoryKV)};
  
  //展示已知数据
  var ins1 = table.render({
    elem: '#orderList'
    ,cols: [[ //标题栏
      {field: 'client_ordernum', title: '订单号', width: 100, sort: true}
      ,{field: 'factory_id', title: '所属工厂', width: 150, sort: true,templet:function(d){return factoryKV[d.factory_id]}}
      ,{field: 'quantity', title: '数量', width: 80, sort: true}
      ,{field: 'status_txt', title: '状态', width: 100, sort: true}
      ,{field: 'create_time', title: '时间', width: 160, sort: true, templet:"<div>{{layui.util.toDateString(d.create_time*1000)}}</div>"}
    ]]
    ,toolbar: '#toolbar'
    ,defaultToolbar: ['filter', 'print', {
        title: '导出全部数据'
            ,layEvent: 'MIMO_EXPORT'
            ,icon: 'layui-icon-export'
        }]
	,initSort: {field:'create_time', type:'desc'}
    ,data: orderList
    //,skin: 'line' //表格风格
    ,even: true
    ,page: true //是否显示分页
    ,limits: [20, 50, 100, 500, 1000,10000]
    ,limit: 20 //每页默认显示的数量
  });
  
  //头工具栏事件
  table.on('toolbar(orderList)', function(obj){
	  switch(obj.event){
      case 'MIMO_EXPORT':
    	  table.exportFile(ins1.config.id, orderList, 'xls'); 
      break;
    };
  });
  
});
</script>